<?php

class Application_Model_Mapper_KoordinatenMapper
{
	protected $_dbTable;

	public function setDbTable ($dbTable)
	{
		
		if (is_string($dbTable))
		{
			$dbTable = new $dbTable();
		}
		if (! $dbTable instanceof Zend_Db_Table_Abstract)
		{
			throw new Exception('Invalid table data gateway provided');
		}
		$this->_dbTable = $dbTable;
		return $this;
		
	}

	public function getDbTable ()
	{
		
		if (null === $this->_dbTable)
		{
			$this->setDbTable('Application_Model_DbTable_Koordinaten');
		}
		return $this->_dbTable;
		
	}

	public function add(Application_Model_Koordinaten $kords)
	{				
		$data = array(
				'lat' => $kords->getLat(),
				'lng' => $kords->getLng(),
				'hohe' => $kords->getHohe()
		);
	
		return $this->getDbTable()->insert($data);
	}

	public function fetchID($id)
	{
		$db = Zend_Db_Table::getDefaultAdapter();
		$entry = new Zend_Db_Select($db);
		$entry->from('group');
		$entry->where('group.id = ?', $id);
		return $entry->query()->fetch();
	}

}




